/**
  * @Description: WoShop商城
  * @Author: 梧桐
  * @Copyright: 武汉一一零七科技有限公司©版权所有
  * @Link: www.wo-shop.net
  * @Contact: QQ:2487937004
  */
<template>
    <view class="checkorder">
		
		<view class="checkorder-item" @click="saoma()" v-if="h5">
			<view class="checkorder-item-left">
				<view class="checkorder-text1">{{$t('扫码核销')}}</view>
				<view class="checkorder-text2">{{$t('扫一扫便捷核销')}}</view>
			</view>
			<view class="checkorder-item-right">
				<image class="checkorder-image" src="https://uploadfile.wo-shop.net/uploads/ad/20220731/4b93eb71c6009765304b9a6c72b42938.png"></image>
			</view>
		</view>
		
		
		<view class="checkorder-item" @click="checkorderDetail()">
			<view class="checkorder-item-left">
				<view class="checkorder-text1">{{$t('核销码核销')}}</view>
				<view class="checkorder-text2">{{$t('核销精准验证')}}</view>
			</view>
			<view class="checkorder-item-right">
				<image class="checkorder-image" src="https://uploadfile.wo-shop.net/uploads/ad/20220731/55e437e73900df1316ba5445db94b0fd.png"></image>
			</view>
		</view>
			
		<view class="checkorder-item" @click="$u.route('/pagesC/order/checkorderList')">
			<view class="checkorder-item-left">
				<view class="checkorder-text1">{{$t('核销记录')}}</view>
				<view class="checkorder-text2">{{$t('记录随时可查')}}</view>
			</view>
			<view class="checkorder-item-right">
				<image class="checkorder-image" src="https://uploadfile.wo-shop.net/uploads/ad/20220731/8262cffe70ea562d3ee9cf39a52ed624.png"></image>
			</view>
		</view>
		
		<u-popup ref="popupCheckorder" mode="bottom" border-radius="12">
			<view class="checkorder-title">{{$t('核销码核销')}}</view>
			<view class="checkorder-list">
				<input v-model="check_order_sn" placeholder="请输入核销订单号"/>
			</view>
			<view class="checkorder-com">
				<button @click="hidePopup">{{$t('完成')}}</button>
			</view>
		</u-popup>
		
    </view>
</template>

<script>
export default {
    data(){
        return {
			h5:1,
			check_order_sn:'',
        }
    },
    onLoad(){
		//#ifdef H5
		this.h5 = 0;
		//#endif
    },
    methods: {
		
		//扫码核销
		saoma(){
			var that = this;
			uni.scanCode({
				success: function (res) {
					console.log('条码类型：' + res.scanType);
					console.log('条码内容：' + res.result);
					that.check_order_sn = res.result;
					that.hidePopup();
				}
			});
		},
		
		//核销详情
		checkorderDetail(){
			this.$refs.popupCheckorder.open();
		},
		
		
		hidePopup() {
			if(this.check_order_sn == ""){
				this.$toast(this.$t('核销码不能为空'));
				return;
			}
			this.$http.checkOrderDetail({check_order_sn:this.check_order_sn}).then(res => {
			  if (res.status === 200) {
				  this.getnav('/pagesC/order/checkorderDetail?order_num='+res.data.ordernumber);
				  this.$refs.popupCheckorder.close(); // 关闭
			  }
			}).catch(() => {
			})
		}
		
    },
}
</script>

<style lang="scss" scoped>
	.checkorder{
		margin:20upx;
		.checkorder-item:not(:first-child){
			margin-top:20upx;
		}
		.checkorder-item{
			background-color:#FFFFFF;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			height:300upx;
			padding-top:50upx;
			.checkorder-item-left{
				padding:10upx;
				padding-left:50upx;
				.checkorder-text1{
					font-size:30upx;
					font-weight: bold;
					height:80upx;
					line-height: 80upx;
				}
				.checkorder-text2{
					font-size:26upx;
					color:#999;
					
				}
			}
			.checkorder-item-right{
				padding-right:50upx;
				.checkorder-image{
					width:200upx;
					height:200upx;
				}
			}
		}
	}
	.checkorder-title{
		width: 100%;
		height: 40px;
		line-height: 40px;
		font-size: 15px;
		text-align: center;
	}
	.checkorder-list{
		padding:100upx 10upx;
		input{
			border:1upx solid #999;
			height:100upx;
			padding:0 10upx;
			border-radius:30upx;
		}
	}
	.checkorder-com{
		padding: 10upx 30upx;
		button{
			width: 100%;
			border-radius: 40upx;
			height: 80upx;
			line-height: 80upx;
			background-color: #FA3F3F;
			text-align: center;
			color: #fff;
		}
	}
</style>
